-
Notifications
You must be signed in to change notification settings - Fork 2
Exo2 2 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: thibault
Are you sure you want to change the base?
Exo2 2 #11
Conversation
…ge et jamais de decryptage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ton algo est top et très clair. Il n'y a quasi rien à changer, juste des détails, important, mais des détails.
|
||
|
||
def crack_key(cypher_text: str) -> int: | ||
"""Finde key""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On va essayer d'éméliorer cette docstring... elle est pas là juste pour décorer !
"""Finde key""" | ||
ALPHABET = list(string.ascii_uppercase) | ||
CYPHER_TEXT = list(cypher_text) | ||
list_occurence_by_letter = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On évite généralement de mettre le type d'une variable dans son nom (car souvent au cours de la vie d'un code, on change les types !)
CYPHER_TEXT = list(cypher_text) | ||
list_occurence_by_letter = [] | ||
for letter in ALPHABET: | ||
occurrence = CYPHER_TEXT.count(letter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Très bonne idée d'utiliser count 👍
INDEX_LETTER_MOST_OCCURENCE = list_occurence_by_letter.index( | ||
max(list_occurence_by_letter) | ||
) | ||
LIKELY_TO_BE_E = ALPHABET[INDEX_LETTER_MOST_OCCURENCE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cette ligne est super belle 👍
|
||
|
||
def do_decipher(cypher_text: str, key: int) -> str: | ||
"""Decipher text """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comme pour l'autre fonction : il faudrait améliorer cette docstring. Genre au moins dire qu'onle fait avec la clé...
No description provided.